//
//  NSData+ext.m
//  WanLian
//
//  Created by 123456 on 2019/1/8.
//  Copyright © 2019 wanlian. All rights reserved.
//

#import "NSData+ext.h"

@implementation NSData (ext)

- (int32_t)readIntWithLocation:(int)location {
    if (self.length >= (location + 4)) {
        NSData *data4 = [self subdataWithRange:NSMakeRange(location, 4)];
        int32_t value = CFSwapInt32BigToHost(*(int32_t*)([data4 bytes]));
        return value;
    }
    return -1;
}
@end
